<template>
  <el-form :model="form" :inline="true" size="default">
    <el-form-item>
      <el-input v-model="form.name" placeholder="请输入部门名称"></el-input>
    </el-form-item>
    <el-form-item>
      <el-input v-model="form.location" placeholder="请输入部门所在地"></el-input>
    </el-form-item>

    <el-form-item>
      <el-button @click="handleSearchClick">搜索</el-button>
      <el-button type="danger" @click="handleResetClick" plain>重置
      </el-button>
      <el-button type="primary" @click="handleAddClick">新增</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup lang="ts">
import { toRefs } from 'vue'
import { emitter, useDepartmentStore } from '@/stores/department.store.ts'
import { storeToRefs } from 'pinia'
import { useDepartmentSearch } from '@/hooks/department.hook.ts'

const store = useDepartmentStore()
const { search } = storeToRefs(store)
const {
  form
} = toRefs(search.value)

const { clearSearchForm } = useDepartmentSearch()

function handleSearchClick() {
  emitter.emit('search_search_btn_clicked')
}

function handleResetClick() {
  clearSearchForm()
  emitter.emit('search_reset_btn_clicked')
}

function handleAddClick() {
  emitter.emit('search_add_btn_clicked')
}
</script>


<style scoped lang="scss">

</style>
